package struts.com;

import java.lang.reflect.Field;

import javax.servlet.http.HttpServletRequest;

public class ReflectUtil {

	public static Object invoke(String path, HttpServletRequest request) {
		Object obj = null;
		try {
			Class<?> clazz = Class.forName(path);
			obj = clazz.newInstance();
			
			Field[] fs = clazz.getDeclaredFields();
			for(Field f:fs) {
				
				f.setAccessible(true);
				f.set(obj, request.getParameter(f.getName()));
				f.setAccessible(false);
			}
			
		} catch (Exception e) {
			// TODO 自动生成的 catch 块
			e.printStackTrace();
			
		}
		
		return obj;
	}
}
